<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Flot Examples</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css"></link>
    <!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
    <script language="javascript" type="text/javascript" src="../jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
    <script language="javascript" type="text/javascript" src="../jquery.flot.navigate.js"></script>
    

 </head>
    <body>

	
	
	    <div id="placeholder" style="width:300px;height:300px;"></div>
	    <div id="clickdata"></div>
		<div id="pageholder" style="position:relative;">

	
	


<script id="source" language="javascript" type="text/javascript">

function load(){
	setGraphSize();
	window.mGraphHandler.loadGraph();
	times++;
}

function setStyle(objId, style, value) {
    document.getElementById(objId).style[style] = value;
}

function setGraphSize(){
	setStyle("placeholder","height",window.mGraphHandler.getGraphHeight()+"px");
	setStyle("placeholder","width",window.mGraphHandler.getGraphWidth()+"px");
}

function GotGraph(data,options,display) {
	var plot = $.plot($("#placeholder"), data, options);
	
	     $("#placeholder").bind("plotclick", function (event, pos, item) {
	            if (item) {
	            		if(display == true){
						//display details                    
	                    var x = item.datapoint[0].toFixed(0),
	                    var y = item.datapoint[1].toFixed(2);
	                    var xtime = new Date(x/1);
	 					$("#clickdata").text(y +" (recorded "+xtime.toLocaleString()+")"); 
						}  

						
						//call the handler for more action
	                	window.mGraphHandler.onClick(item.dataIndex);
	                
	            }
	            
	            //pan graph	
	            var diffX = "";
	            var diffY = 0;	
				var axes = plot.getAxes();
				
				
				var centery = (axes.yaxis.p2c(axes.yaxis.max) - axes.yaxis.p2c(axes.yaxis.min))/2.00 ;
				centery += axes.yaxis.p2c(axes.yaxis.min);
				diffY += (axes.yaxis.p2c(pos.y) - centery).toFixed(0)/1;
				
				
				var centerx =  (axes.xaxis.p2c(axes.xaxis.max) - axes.xaxis.p2c(axes.xaxis.min))/2.00 ;
				centerx += axes.xaxis.p2c(axes.xaxis.min);
				diffX += (axes.xaxis.p2c(pos.x) - centerx).toFixed(0)/1;


				plot.pan({ left:  diffX, top: diffY })
				var args = { left: diffX , top: diffY };
				//$("#clickdata").text("diff "+args.left+","+args.top); 
	
	        
	    }); 
	    
	 // add zoom out button 
    $('<div class="button" style="position:absolute;right:50%; top:0px"> <img src="../imgs/btn_zoom_down_normal.9.png" alt="zoom out"/></div>').appendTo($("#pageholder")).click(function (e) {
        e.preventDefault();
        plot.zoomOut();
    });
    
   // add zoom in button 
    $('<div class="button" style="position:absolute;left:50%; top:0px"><img src="../imgs/btn_zoom_up_normal.9.png" alt="zoom in"/></div>').appendTo($("#pageholder")).click(function (e) {
        e.preventDefault();
        plot.zoom();
    });
	    
	 //ok we are done
	window.mGraphHandler.onGraphRendered()
}

load();
</script>

 </body>
</html>
